package top.kaoshanji.r5ch12d;

/**
 * @author kaoshanji
 * ^_^
 * create time 2025/5/11 10:20
 */
public class MyThread extends Thread {

    private ScoreService scoreService;
    private String userName;
    private int toAdd;

    public MyThread(ScoreService scoreService, String userName, int toAdd) {
        this.scoreService = scoreService;
        this.userName = userName;
        this.toAdd = toAdd;
    }

    @Override
    public void run() {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("...执行scoreService.addScor方法之前...");
        scoreService.addScore(userName, toAdd);
        System.out.println("...执行scoreService.addScor方法之后...");

    }
}
